package com.strutsDeom;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;

import java.util.Map;

public class HelloWorldAction implements Action {
    //用户输入的姓名
    private String name="";
    //向用户展示的信息
    private String message="";

    //用户密码
    private String userPassWord;

    public String getUserPassWord() {
        return userPassWord;
    }

    public void setUserPassWord(String userPassWord) {
        this.userPassWord = userPassWord;
    }



    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String execute(){
        /*if("jason".equals(name) && "2010".equals(userPassWord)){
            //登陆成功，返回usccess
            this.setMessage("欢迎您，"+name);
            return Action.SUCCESS;
        }else {
            //登陆失败，返回error
            return Action.ERROR;
        }*/
        if("jason".equals(name) && "2010".equals(userPassWord)){
            //获取session
            Map<String,Object> session=null;
            session= ActionContext.getContext().getSession();
            session.put("CURRENT_USER",name);
            return Action.SUCCESS;
        }else {
        //登陆失败，返回error
        return Action.ERROR;
    }
    }
}
